/* eslint-disable @typescript-eslint/ban-ts-comment */
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import type { App } from 'vue';
import { routerJumpRedefine } from './guard/routerJumpRedefine'; // 路由跳转方法重写
import notFound from '@/components/Exception/index.vue';
import userModule from './modules/userModule'; // 用户管理
import feedbackModule from './modules/feedbackModule'; // 意见反馈管理
import productmsgModule from './modules/productmsgModule'; // 产品信息管理
import documentModule from './modules/documentModule'; // 文档管理
import appModule from './modules/appModule'; // 应用版本管理
import rankingModule from './modules/rankingModule'; // 应用版本管理
// import storeModule from './modules/storeModule'; // 门店商户管理
// import contentModule from './modules/contentModule'; // 内容管理
import authModule from './modules/authModule'; // 权限管理
import systemModule from './modules/systemModule'; // 系统管理
export const constRouterMap: any = [
  {
    path: '/home',
    name: 'home',
    meta: {
      title: '首页',
      icon: 'home-outlined',
    },
    component: () => import('@/views/home/home.vue'),
  },
  {
    path: '/person/msg',
    name: 'personal-msg',
    meta: {
      title: '个人设置',
    },
    hidden: true,
    component: () => import('@/views/personal/msg.vue'),
  },
];

export const asyncRouterMap: Array<RouteRecordRaw> = [
  {
    path: '/',
    meta: {
      title: '首页',
      icon: 'icon-icon_nav_work_nor',
    },
    name: 'index',
    redirect: '/home',
    component: () => import('@/views/index.vue'),
    children: [
      ...authModule,
      ...userModule,
      ...feedbackModule,
      ...productmsgModule,
      ...documentModule,
      ...appModule,
      ...rankingModule,
      ...systemModule,
      // ...storeModule,
      // ...contentModule,
      // ...orderModule,
    ],
  },
];

const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'login',
    meta: {
      title: '登录',
    },
    component: () => import('@/views/login/index.vue'),
  },
  {
    path: '/exception',
    name: 'exception',
    component: () => import('@/views/index.vue'),
    children: [
      {
        path: '/:path(.*)*',
        name: 'notFound',
        component: notFound, // 引入 组件
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

// 路由跳转方法重写
routerJumpRedefine(router)

export function setupRouter(app: App<Element>) {
  app.use(router);
}

export default router;
